<template>
    <div>
        <v-header v-if="!$root.ISAPP">
            <div class="nav-tab2">
                <h3>助力享低价</h3>
            </div>
            <!-- <v-cart :isshow="true" :isdark="true"></v-cart> -->
        </v-header>
         <!-- <div style="margin:0 auto;display:none;">
             <img src="https://files.eyee.com/EYEE/share/weixin/wx_share_list_white_1x.png" />
           </div> -->
         <broadcast :bannertype='bannertype'></broadcast>
        <router-view></router-view>
        <div class="fix-btm">
            <div class="helpTap ">
                <!-- <router-link to="/helpbargain" id="list">助力列表</router-link>
                <router-link to="/helpbargain/helporder">我的助力</router-link> -->
                <a href="javascript:void(0)" :class="activeIndex===index?'active':''" v-for="(item,index) in url" @click.stop="push(item.pushUrl,index)">{{item.title}}</a>
            </div>
        </div>
        
    </div>
     
</template>
<script>
import { getUrlParam } from "../../common/util.js";
import broadcast from "./broadcast.vue";
export default {
  data() {
    return {
      url: [
        { pushUrl: "/helpbargain", title: "助力商品" },
        { pushUrl: "/helpbargain/helporder", title: "我的助力" }
      ],
      activeIndex: 0,
      bannertype: true
    };
  },
  components: { broadcast },
  created() {
    try {
      if (this.$root.ISAPP) {
        let param = getUrlParam("param");
        param = JSON.parse(decodeURIComponent(param))
        if (param.token) {
          localStorage.setItem("currentUser", JSON.stringify(param));
        }
      }
    } catch (e) {
      console.error(' ',e)
    }
  },
  mounted() {
    if (window.location.href.indexOf("helpbargain/helporder") > 0) {
      this.bannertype = false;
      this.activeIndex = 1;
    } else {
      this.bannertype = true;
      this.activeIndex = 0;
    }
  },
  watch: {
    //监听路由变化
    $route(to, from) {
      if (to.fullPath.indexOf("helpbargain/helporder") > 0) {
        this.bannertype = false;
        this.activeIndex = 1;
      } else {
        this.bannertype = true;
        this.activeIndex = 0;
      }
    }
  },
  computed: {},
  methods: {
    push(url, index) {
      this.activeIndex = index;
      this.$router.replace(url);
    }
  }
};
</script>
<style scoped>
/* .in-out-translate-fade */
body {
  padding-bottom: 0 !important;
}
.fix-btm {
  position: fixed;
  left: 0;
  bottom: -1px;
  width: 100%;
  background: #fff;
  z-index: 1;
}
.active {
  background: #333;
}
.helpTap {
  height: 44px;
  text-align: center;
  background: #ccc;
}
.helpTap a {
  float: left;
  width: 50%;
  line-height: 44px;
  color: #fff;
  /* background: #ccc; */
}
.helpTap a.router-link-exact-active {
  background: #333;
}
</style>


